<?php
/**
 * Created by JetBrains PhpStorm.
 * User: миха
 * Date: 22.07.13
 * Time: 15:33
 * To change this template use File | Settings | File Templates.
 */
class Controller_Subcategory extends Controller_Default
{
    function __construct($subCategoryId, $filter)
    {
        $this->getSubCategory($subCategoryId, $filter);
    }

    private function getSubCategory($subCategoryId, $filter)
    {
        $subCategoryId = (int)$subCategoryId;

        $OrderBy = $this->filter($filter);;
        $OrderBy = $this->getDefaultOrderBy($OrderBy);
        $mode = new Model_Subcategory();
        $subCategoryInfo = $mode->getSubCategoryData($subCategoryId, $OrderBy);
        //var_dump($subCategoryInfo);

        $view = new View_Subcategory();
        $view->pageContent = $subCategoryInfo;
        $this->view = $view->view();
        $this->pagination(get_class(), $subCategoryId);
        $this->render("mainPage.twig");
    }
}